﻿using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace bonus.Models
{
	public class Order
	{
		/// <summary>
		/// ID
		/// </summary>
		public ObjectId _id { get; set; }

		/// <summary>
		/// 订单编号
		/// </summary>
		public string OrderNo { get; set; }

		/// <summary>
		/// 售货人名称
		/// </summary>
		public string SaleName { get; set; }

		/// <summary>
		/// 售货人编号
		/// </summary>
		public string SaleNo { get; set; }

		/// <summary>
		/// 收货人
		/// </summary>
		public string UserName { get; set; }

		/// <summary>
		/// 联系方式
		/// </summary>
		public string Mobile { get; set; }

		/// <summary>
		/// 收货地址
		/// </summary>
		public string Add { get; set; }

		/// <summary>
		/// 详细地址
		/// </summary>
		public string Address { get; set; }

		/// <summary>
		/// 顾客要求/备注
		/// </summary>
		public string Remarks { get; set; }

		/// <summary>
		/// 订单金额
		/// </summary>
		public decimal Money { get; set; }

		/// <summary>
		/// PV值
		/// </summary>
		public int PV { get; set; }

		/// <summary>
		/// 服务中心/报单账户
		/// </summary>
		public string AddPC { get; set; }

		/// <summary>
		/// 打款流水编号
		/// </summary>
		public string Wather { get; set; }

		/// <summary>
		/// 购买方式(服务中心下单,公司下单,总公司下单)
		/// </summary>
		public int BuyType { get; set; }

		/// <summary>
		/// 类型（学员零售0、学员注册1）
		/// </summary>
		public string Type { get; set; }

		/// <summary>
		/// 学员编号
		/// </summary>
		public string UserNo { get; set; }

		/// <summary>
		/// 产品列表
		/// </summary>
		public List<Product> Products { get; set; }

		/// <summary>
		/// 订单状态
		/// </summary>
		public int State { get; set; }

		#region 状态

		/// <summary>
		/// 状态
		/// </summary>
		public class StateClass
		{
			/// <summary>
			/// 已报单/待审核
			/// </summary>
			public static readonly int AFFAIRES = 0;

			/// <summary>
			/// 已通过审核/待标记(已发货,待发货)
			/// </summary>
			public static readonly int PASS = 1;

			/// <summary>
			/// 已取消
			/// </summary>
			public static readonly int CANCEL = 2;

			/// <summary>
			/// 待发货
			/// </summary>
			public static readonly int DAIFAHUO = 3;

			/// <summary>
			/// 已发货
			/// </summary>
			public static readonly int YIFAHO = 4;

			/// <summary>
			/// 已完成
			/// </summary>
			public static readonly int YIWANCHENG = 5;

			public static string GetState(int Status)
			{
				string StatusDesc = string.Empty;
				switch (Status)
				{
					case 0:
						StatusDesc = "待审核";
						break;
					case 1:
						StatusDesc = "已通过";
						break;
					case 2:
						StatusDesc = "已取消";
						break;
					case 3:
						StatusDesc = "待发货";
						break;
					case 4:
						StatusDesc = "已发货";
						break;
					case 5:
						StatusDesc = "已完成";
						break;
					default:
						StatusDesc = "异常";
						break;
				}
				return StatusDesc;
			}



		}

		#endregion

		/// <summary>
		/// 添加时间
		/// </summary>
		[BsonDateTimeOptions(Kind = DateTimeKind.Local)]
		public DateTime AddDT { get; set; }
	}


	public class Product
	{
		/// <summary>
		/// 产品编码
		/// </summary>
		public string No { get; set; }

		/// <summary>
		/// 产品名称
		/// </summary>
		public string Name { get; set; }

		/// <summary>
		/// 产品需要
		/// </summary>
		public int Sort { get; set; }

		/// <summary>
		/// 产品单价
		/// </summary>
		public decimal Money { get; set; }

		/// <summary>
		/// 产品数量
		/// </summary>
		public int Num { get; set; }

	}


}